package com.d3works.apps.supplychain.service;

import com.d3works.apps.purchase.db.PurchaseOrder;
import com.d3works.apps.purchase.db.PurchaseOrderLine;
import com.d3works.apps.stock.db.StockMove;
import com.d3works.apps.stock.db.StockMoveLine;
import com.d3works.exception.D3worksException;
import java.math.BigDecimal;
import java.util.List;

public interface PurchaseOrderStockService {

  /**
   * Méthode permettant de créer un StockMove à partir d'un PurchaseOrder.
   *
   * @param purchaseOrder une commande
   * @throws D3worksException Aucune séquence de StockMove n'a été configurée
   */
  public List<Long> createStockMoveFromPurchaseOrder(PurchaseOrder purchaseOrder)
      throws D3worksException;

  public StockMoveLine createStockMoveLine(
      StockMove stockMove,
      StockMove qualityStockMove,
      PurchaseOrderLine purchaseOrderLine,
      BigDecimal qty)
      throws D3worksException;

  public void cancelReceipt(PurchaseOrder purchaseOrder) throws D3worksException;

  public boolean isStockMoveProduct(PurchaseOrderLine purchaseOrderLine) throws D3worksException;

  public boolean isStockMoveProduct(
      PurchaseOrderLine purchaseOrderLine, PurchaseOrder purchaseOrder) throws D3worksException;

  // Check if existing at least one stockMove not canceled for the purchaseOrder
  public boolean existActiveStockMoveForPurchaseOrder(Long purchaseOrderId);

  public void updateReceiptState(PurchaseOrder purchaseOrder) throws D3worksException;

  /**
   * Create a query to find purchase order line of a product of a specific/all company and a
   * specific/all stock location
   *
   * @param productId
   * @param companyId
   * @param stockLocationId
   * @return the query.
   */
  public String getPurchaseOrderLineListForAProduct(
      Long productId, Long companyId, Long stockLocationId);
}
